package vuelta.general.adapter;

import vuelta.general.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class SquadreArrayAdapter extends ArrayAdapter<String> {
	private final Context context;
	private final String[] values;

	public SquadreArrayAdapter(Context context, String[] values) {
		super(context, R.layout.list_squadre, values);
		this.context = context;
		this.values = values;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.list_squadre, parent, false);
		TextView textView = (TextView) rowView.findViewById(R.id.label);
		ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
		textView.setText(values[position]);

		// cambia immagine a seconda della squadra
		String s = values[position];
		if (s.startsWith("Liquigas")) {
			imageView.setImageResource(R.drawable.liquigas);
		}
		if (s.startsWith("AG2R La Mondiale")) {
			imageView.setImageResource(R.drawable.maglia_ag2r);
		}
		if (s.startsWith("Cofidis")) {
			imageView.setImageResource(R.drawable.maglia_cofidis);
		}

		if (s.startsWith("BMC Racing Team")) {
			imageView.setImageResource(R.drawable.maglia_bmc);
		}

		if (s.startsWith("Argos Shimano")) {
			imageView.setImageResource(R.drawable.maglia_argos_shimano);
		}

		if (s.startsWith("Euskaltel")) {
			imageView.setImageResource(R.drawable.maglia_euskaltel);
		}

		if (s.startsWith("Caja")) {
			imageView.setImageResource(R.drawable.maglia_caja_rural);
		}
		if (s.startsWith("FDJ")) {
			imageView.setImageResource(R.drawable.maglia_fdj);
		}
		if (s.startsWith("Orica")) {
			imageView.setImageResource(R.drawable.maglia_green_edge);
		}

		if (s.startsWith("Katusha Team")) {
			imageView.setImageResource(R.drawable.maglia_katusha);
		}

		if (s.startsWith("Lampre")) {
			imageView.setImageResource(R.drawable.maglia_lampre);
		}
		if (s.startsWith("Liquigas")) {
			imageView.setImageResource(R.drawable.maglia_liquigas);
		}
		if (s.startsWith("Lotto Belisol")) {
			imageView.setImageResource(R.drawable.maglia_lotto);
		}

		if (s.startsWith("Movistar Team")) {
			imageView.setImageResource(R.drawable.maglia_movistar);
		}
		if (s.startsWith("Omega Pharma")) {
			imageView.setImageResource(R.drawable.maglia_omega);
		}
		if (s.startsWith("Pro Team Astana")) {
			imageView.setImageResource(R.drawable.maglia_pro_astana);
		}
		if (s.startsWith("Rabobank Cycling Team")) {
			imageView.setImageResource(R.drawable.maglia_rabobank);
		}
		if (s.startsWith("Saxo Bank")) {
			imageView.setImageResource(R.drawable.maglia_saxo);
		}
		if (s.startsWith("Sky")) {
			imageView.setImageResource(R.drawable.maglia_sky);
		}
		if (s.startsWith("Garmin")) {
			imageView.setImageResource(R.drawable.maglia_garmin);
		}
		if (s.startsWith("Anda")) {
			imageView.setImageResource(R.drawable.maglia_andalucia);
		}
		if (s.startsWith("Radioshak")) {
			imageView.setImageResource(R.drawable.maglia_nissan_trek);
		}

		if (s.startsWith("Vacansoleil Pro Cycling Team")) {
			imageView.setImageResource(R.drawable.maglia_vacansoleil);
		}

		return rowView;
	}
}